package php.code.instructions;

import php.code.Visibility;
import php.code.routines.PhpClass;

public final class Property extends Instruction {

    protected final Visibility visibility;
    private final String name;
    private final Object value;

    public Property(PhpClass phpClass, Visibility visibility, String name, Object value) {
        super(phpClass, true);
        this.name = name;
        this.visibility = visibility;

        this.value = value instanceof String ? "'" + value + "'" : value;
    }

    @Override
    protected String getCode() {
        return String.format("%s%s $%s = %s;",
                getIndentation(),
                visibility,
                name,
                value
        );
    }
}
